import * as validate from './validate'

function getValidator(required, validateName, number) {
  const arr = []
  if (required != null) {
    arr.push({
      required: true,
      message: required,
      trigger: 'blur'
    })
  }
  if (validateName != null) {
    arr.push({
      validator: validate[validateName],
      trigger: 'blur'
    })
  }
  if (number) {
    arr.push({
      type: 'number',
      min: 0,
      message: '请输入正确的数字',
      trigger: 'blur'
    })
  }
  return arr
}

const login = {
  userId: getValidator('请输入用户名'),
  password: getValidator('请输入密码')
}

const dictionary = {
  code: getValidator('请输入字典编号'),
  name: getValidator('请输入字典名称'),
  visitedNetworkAddress: getValidator('请选择字典状态')
}

const app = {
  name : getValidator('请输入APP名称'),
  itemId : getValidator('请输入授权项编号'),
  type : getValidator('请选择授权项类型')
}

const customer = {
  code : getValidator('请输入客户编号'),
  name : getValidator('请输入客户名称'),
  contacter : getValidator('请输入联系人'),
  phone : getValidator('请输入联系人号码')
}

const author = {
  custCode : getValidator('请选择客户'),
  fingerprint : getValidator('请输入指纹信息'),
  key1 : getValidator('请选择Code1'),
  key1 : getValidator('请选择Code2')
}

const client = {
  authorize : getValidator('请选择授权中心'),
  appId : getValidator('请选择授权APP'),
  num : getValidator('请输入授权数量'),
  keyId : getValidator('请选择户端秘钥')
}

const key = {
  type : getValidator('请选择秘钥类型'),
  remark : getValidator('请输入秘钥名称')
}

export {
  login,
  dictionary,
  app,
  customer,
  author,
  client,
  key
}
